package net.zdreamer.shunyi.ui.myinfo;


import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Toast;

import net.zdreamer.shunyi.R;

public class SearchActivity extends Activity implements SearchView.OnQueryTextListener {
    private SearchView search;

    private ListView list;

    private final String[] mStrings = {"aaaaaa", "asdfg", "bbbbbb", "cccccc"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        list = (ListView) findViewById(R.id.serchlist);
        list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings));
        list.setTextFilterEnabled(true);


        search = (SearchView) findViewById(R.id.search_view);
        search.setIconifiedByDefault(false);
        search.setOnQueryTextListener(this);
        search.setSubmitButtonEnabled(false);
    }

    @Override
    public boolean onQueryTextSubmit(String query) {
        //  Toast.makeText(this, "您选择的是" + query, Toast.LENGTH_LONG).show();
        return false;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
        if (TextUtils.isEmpty(newText)) {
            list.clearTextFilter();
        } else {
            list.setFilterText(newText);
        }
        return true;
    }
}
